# 处理牙防和儿牙的数据
# 最终形成的数据是包括：姓名，科室，职称级别，职称名称4要素

import yaml
import os
import pandas as pd

with open(os.path.join('data_src','name_title.yaml'),encoding='utf8') as yml:
    yaml_data = yaml.safe_load(yml)


def df_data_extract(name_list):
    splitter = '，'
    df = pd.DataFrame(name_list).rename(columns={0:'name'})
    df[['name','title']] = df['name'].str.split(splitter,expand=True)

    title_class_dict = {
        '主治医师':'中级',
        '主管护师':'中级',
        '副主任医师':'副高',
        '医师':'初级',
        '护士':'初级',
        '护师':'初级',
    }

    title_class_expense_budget_dict = {
        '初级':400,
        '中级':500,
        '副高':800,
        '正高':1000,
    }

    yhj_class_dict = {
        '主治医师': '医师',
        '主管护师': '护士',
        '副主任医师': '医师',
        '医师': '医师',
        '护士': '护士',
        '护师': '护士',
    }
    df['title_class'] = df['title'].map(title_class_dict)
    df['yhj_class'] = df['title'].map(yhj_class_dict)
    df['expense_budget'] = df['title_class'].map(title_class_expense_budget_dict)
    df = df.set_index('name')
    return df


df_yafang = df_data_extract(yaml_data['牙防人员'])
df_yafang['department'] = 'yf牙防'
df_erya = df_data_extract(yaml_data['儿牙人员'])
df_erya['department'] = 'er儿牙'


df_rst = pd.concat([df_yafang,df_erya])
df_rst.to_csv('name_list_erya_yafang.csv')


